/**
 * initialize your data structure here.
 */
var MinStack = function () {
	this.x_stack = [];
	// 辅助最小栈
	this.min_stack = [Infinity];
};

/** 
 * @param {number} x
 * @return {void}
 */
MinStack.prototype.push = function (x) {
	this.x_stack.push(x);
	// 将新推入的元素和最小栈的栈顶元素对比，
	// 保证最小栈的栈顶元素是最小的元素
	this.min_stack.push(Math.min(this.min_stack[this.min_stack.length - 1], x));
};

/**
 * @return {void}
 */
MinStack.prototype.pop = function () {
	this.x_stack.pop();
	this.min_stack.pop();
};

/**
 * @return {number}
 */
MinStack.prototype.top = function () {
	// 返回栈顶元素
	return this.x_stack[this.x_stack.length - 1];
};

/**
 * @return {number}
 */
MinStack.prototype.min = function () {
	// 返回最小栈的栈顶元素
	return this.min_stack[this.min_stack.length - 1];
};

/**
 * Your MinStack object will be instantiated and called as such:
 * var obj = new MinStack()
 * obj.push(x)
 * obj.pop()
 * var param_3 = obj.top()
 * var param_4 = obj.min()
 */